<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/assets/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>tab切换页面</legend>
</fieldset>
<div class="layui-tab layui-tab-close">
    <ul class="layui-tab-title">A</ul>
    <ul class="layui-tab-title">B</ul>
    <ul class="layui-tab-title">C</ul>
    <ul class="layui-tab-title">D</ul>

    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">内容A</div>
        <div class="layui-tab-item">内容B</div>
        <div class="layui-tab-item">内容C</div>
        <div class="layui-tab-item">内容D</div>
    </div>
</div>


<p class="layui-elem-quote">其实就是自定义了个“|”的分隔符，然后最后一项也可以点。</p>

<script src="/assets/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use('element', function(){
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块

        //监听导航点击
        element.on('nav(demo)', function(elem){
            //console.log(elem)
            layer.msg(elem.text());
        });
    });
</script>

</body>
</html>